package com.lsf.action;

import java.sql.Timestamp;

import javax.servlet.http.Cookie;

import com.lsf.po.PubMessage;
import com.lsf.po.User;
import com.lsf.service.PubMessageService;
import com.lsf.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

/**

 * 创建日期：2013-3-9上午11:25:15

 * 修改日期：

 * 作者：刘帅飞

 */

public class PostPubMessagesAction extends ActionSupport{
	private String text;
	private String username;
	private Timestamp date;
	private UserService userService;
	private PubMessageService pubMessageService;
	public void setText(String text) {
		this.text = text;
	}
	public String getText() {
		return text;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getUsername() {
		return username;
	}
	public void setDate(Timestamp date) {
		this.date = date;
	}
	public Timestamp getDate() {
		return date;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	public void setPubMessageService(PubMessageService pubMessageService) {
		this.pubMessageService = pubMessageService;
	}
	public String execute() throws Exception {
		
		PubMessage pubMessage = new PubMessage();	
		
		pubMessage.setDate(new Timestamp(System.currentTimeMillis()));	/*设置pubMessage为当前时间*/
		pubMessage.setText(text);	/*设置pubMessage内容*/
		pubMessage.setReadTag(0);/* 设置其是否读过状态，0表示未读状态，1表示*/	
		User user = userService.findUser("admin12");
		pubMessage.setUser(user);/*设置pubMessage用户编号属性*/	
			
		pubMessageService.addPubMessage(pubMessage);
		
		
		
		
		
		return SUCCESS;
		
	}
}
